package com.qfedu.controller;

import com.qfedu.entity.ResponseData;
import com.qfedu.entity.Singer;
import com.qfedu.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/singer")
public class SingerController {

    @Autowired
    private SingerService singerService;

    /**
     * 获取所有歌手
     * @return
     */
    @RequestMapping
    public List<Singer> getAllSinger(){

        return singerService.getAllSinger();
    }

    /**
     * 通过性别对歌手分类
     * @param sex
     * @return
     */
    @RequestMapping("/sex/detail")
    public List<Singer> getSingerOfSex(byte sex){

        return singerService.getSingerOfSex(sex);
    }

    /**
     * 添加歌手
     * @param singer
     * @return
     */
    @RequestMapping("/add")
    public ResponseData<String> addSinger(Singer singer){

        return singerService.addSinger(singer);

    }

    /**
     * 更新歌手信息
     * @param singer
     * @return
     */
    @RequestMapping("/update")
    public ResponseData<String> updateSinger(Singer singer) {

        return singerService.updateSinger(singer);
    }

    /**
     * 删除歌手
     * @param singer
     * @return
     */
    @RequestMapping("/delete")
    public ResponseData<String> deleteSinger(Singer singer){
        return  singerService.deleteSingerById(singer.getId());
    }
}
